﻿using System;
using System.Collections;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using KPIS.GERP.GBMS.BLL;
using KPIS.GERP.GBMS.IBLL;
using KPIS.GERP.GBMS.MODEL;
using Telerik.Web.UI;

namespace KPIS.GERP.GBMS.APP_UI
{
    public partial class StrategyTypeCombo : System.Web.UI.UserControl
    {
        //public event EventHandler SourceTypeChange;
        //public int val = 0;
        //public event EventHandler SourceTypeChange;
        //public int val = 0;
        public RadComboBox ctrChild;
        private IStrategyTypeBLL stratType = new StrategyTypeBLL();
        private IStrategyDataBLL strat = new StrategyDataBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public void LoadStrategyTypeComboBox()
        {
            LoadStrategyTypeComboBox(0);
        }

        public void LoadStrategyTypeComboBox(int seq)
        {
            cbType.DataSource = stratType.Search(seq, "", "", "", "0");
            cbType.DataBind();

            cbType.Items.Insert(0, new RadComboBoxItem("- เลือกประเภทยุทธศาสตร์ -"));
        }

        protected void cbSourceType_SelectedIndexChanged(object o, EventArgs e)
        {
            int val = 0;

            if (cbType.SelectedIndex > 0)
            {
                val = Convert.ToInt32(cbType.SelectedValue);
                if (ctrChild != null)
                {
                    ctrChild.DataSource = strat.Search(0, "", "", "", val);
                    ctrChild.DataBind();

                    ctrChild.Items.Insert(0, new RadComboBoxItem(cbType.Items[0].Text));
                    ctrChild.Focus();
                }
            }
            else
                if (ctrChild != null)
                    ctrChild.Items.Clear();
        }
        public string SelectedValue
        {
            get { return cbType.SelectedValue; }
            set { cbType.SelectedValue = value; }
        }
    }
}